#ifndef CODE_FOC_ENCODER_H_
#define CODE_FOC_ENCODER_H_
#include "zf_common_headfile.h"
#include "zf_common_typedef.h"

#define MENC15A_1_SPI_SPEED            (20 * 1000 * 1000)
#define MENC15A_1_SPI                  (SPI_1           )
#define MENC15A_1_CLK_PIN              (SPI1_SCLK_P11_6 )
#define MENC15A_1_MOSI_PIN             (SPI1_MOSI_P11_9 )
#define MENC15A_1_MISO_PIN             (SPI1_MISO_P11_3 )
#define MENC15A_1_CS_PIN               (P11_2)
#define MENC15A_1_CS(x)                ((x) ? (gpio_high(MENC15A_1_CS_PIN)) : (gpio_low(MENC15A_1_CS_PIN)))

#define MENC15A_2_SPI_SPEED           (20 * 1000 * 1000)
#define MENC15A_2_SPI                 (SPI_3           )
#define MENC15A_2_CLK_PIN             (SPI4_SCLK_P22_3 )
#define MENC15A_2_MOSI_PIN            (SPI4_MOSI_P22_0 )
#define MENC15A_2_MISO_PIN            (SPI4_MISO_P22_1 )
#define MENC15A_2_CS_PIN              (P22_2)
#define MENC15A_2_CS(x)               ((x) ? (gpio_high(MENC15A_2_CS_PIN)) : (gpio_low(MENC15A_2_CS_PIN)))

typedef enum
{
    menc15a_1_module = 0,
    menc15a_2_module = 1,

}menc15a_module_enum;

extern uint16 menc15a_absolute_data[2];
extern int16 menc15a_absolute_offset_data[2];
extern int16  menc15a_speed_data[2];

uint8  menc15a_init(void);
uint16 menc15a_get_absolute_data(menc15a_module_enum menc15a_module);
int16  menc15a_get_speed_data(menc15a_module_enum menc15a_module);

#endif /* CODE_ENCODER_H_ */
